package org.dromara.exam.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.dromara.common.mybatis.annotation.DataColumn;
import org.dromara.common.mybatis.annotation.DataPermission;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.exam.domain.entity.ExamRepo;
import org.dromara.exam.domain.vo.ExamRepoVo;
import org.dromara.exam.domain.vo.RepoInfoVo;

import java.util.List;

/**
 * 题库Mapper接口
 *
 * @author xiyin321
 * @date 2024-04-11
 */
public interface ExamRepoMapper extends BaseMapperPlus<ExamRepo, ExamRepoVo> {

    /**
     * 分页查询题库列表
     *
     * @param tagsIds                  标签ID列表
     * @param build                   分页参数
     * @param examRepoWrapper 查询参数
     * @return 题库集合
     */
    @DataPermission({
        @DataColumn(key = "userName", value = "qb.create_by"),
        @DataColumn(key = "deptName", value = "qb.create_dept")
    })
    Page<ExamRepoVo> selectRepoVoPage(@Param("page") Page<Object> build,
                                      @Param(Constants.WRAPPER) Wrapper<ExamRepo> examRepoWrapper,
                                      @Param("tagIds") List<Long> tagIds,
                                      @Param("matchMode") Integer matchMode);

    int updateTypeCount(ExamRepo update);

    /**
     * 查询题库列表
     *
     * @param wrapper 查询参数
     * @return 题库集合
     */
    @DataPermission({
        @DataColumn(key = "userName", value = "create_by"),
    })
    List<ExamRepoVo> selectRepoVoList(@Param(Constants.WRAPPER) Wrapper<ExamRepo> wrapper);

    List<RepoInfoVo> queryListAndTemplate(@Param(Constants.WRAPPER) Wrapper<ExamRepo> wrapper);
   RepoInfoVo queryListAndTemplateByUnion();
}
